// pages/distribut/today_customer/today_customer.js
var app = getApp();
var request = app.request;
var setting = app.globalData.setting;
var common = require('../../../utils/common.js');
var util = require('../../../utils/util.js');
import LoadMore from '../../../utils/LoadMore.js'
var load = new LoadMore;
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
    url:setting.url,
		isTableShow: true,
		table_list: [{
				id: 0,
				name: "张三",
				number: "12",
				price: "456.88"
			},
			{
				id: 1,
				name: "张三风",
				number: "4",
				price: "56.88"
			},
			{
				id: 2,
				name: "张三题",
				number: "10",
				price: "356.88"
			},
			{
				id: 3,
				name: "张三",
				number: "12",
				price: "456.88"
			},
			{
				id: 4,
				name: "张三风",
				number: "4",
				price: "56.88"
			},
			{
				id: 5,
				name: "张三题",
				number: "10",
				price: "356.88"
			},
			{
				id: 6,
				name: "张三",
				number: "12",
				price: "456.88"
			},
			{
				id: 7,
				name: "张三风",
				number: "4",
				price: "56.88"
			},
			{
				id: 8,
				name: "张三题",
				number: "10",
				price: "356.88"
			},
			{
				id: 9,
				name: "张三题",
				number: "10",
				price: "356.88"
			},
			{
				id: 10,
				name: "张三题",
				number: "10",
				price: "356.88"
			},
		],
		yaoqing_list: [{
				id: 0,
				pic: "../../../images/touxiang.png",
				name: "小秋刀鱼"
			},
			{
				id: 1,
				pic: "../../../images/pop.png",
				name: "小秋刀鱼2"
			},
			{
				id: 2,
				pic: "../../../images/touxiang.png",
				name: "小秋刀鱼3"
			}
		],
		time: app.getym(),
		currentdate: {
			hao: new Date().getDate(),
			zj: new Date().getDay(),
			datedq: app.globalData.parseTime(new Date(), '{y}-{m}-{d}'),
			nianyuer: app.globalData.parseTime(new Date(), '{y}年{m}月{d}日'),
		},
		currentlist: app.getDate(new Date()),
		zlist: ['周日', '周一', '周二', '周三', '周四', '周五', '周六', ],
		rectheight: 0,
		info:{},
		list:[],
		currentTab: 1,
		page: 10000,
		one: 0,
		two: 0,
		three: 0,
		currentPage: 1,
	},
	itemclick(e) {
		this.setData({
			time: app.globalData.parseTime(e.detail, '{y}年{m}月'),
			currentlist: app.getDate(e.detail),
			currentdate: {
				hao: new Date(e.detail).getDate(),
				zj: new Date(e.detail).getDay(),
				datedq: app.globalData.parseTime(e.detail, '{y}-{m}-{d}'),
				nianyuer: app.globalData.parseTime(e.detail, '{y}年{m}月{d}日')
			},
			list:[]
		})
		this.getinfo()
		this.getlist()
	},
	itemclick1(e) {
		this.setData({
			currentdate: e.detail,
			list:[]
		})
		this.getinfo()
		this.getlist()
	},
	tableListMore: function(e) {
		var that = this;
		var isTableShow = that.data.isTableShow;
		if (isTableShow == true) {
			that.setData({
				isTableShow: false
			})
		} else {
			that.setData({
				isTableShow: true
			})
		}
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad(options) {
		var that = this;
		this.getinfo()
		this.getlist()
		let query = wx.createSelectorQuery();
		query.select('.test').boundingClientRect(rect => {
			let height = rect.height;
			that.setData({
				rectheight: height
			})
		}).exec()
		
	},
	// 获取订单总数和可邀请会员
	getinfo(){
		let that=this
		request.get('/api/shop/getCustomerByDay', {
			data:{day_time:that.data.currentdate.datedq},
			success: function(res) {
				console.log(res,9999999)
				if (res.data.status == 1) {
					that.setData({
						info: res.data.result
					});
				}
			}
		});
	},
	// 获取下单客户
	getlist(){
		let that=this
		request.get('/api/shop/getCustomerList', {
			data:{day_time:that.data.currentdate.datedq,
			page_no:that.data.currentPage,page_size:that.data.page
			},
			success: function(res) {
				console.log(res,9999999)
				if (res.data.status == 1) {
					that.setData({
						list: res.data.result.data,
						three:res.data.result.count
					});
				}
			}
		});
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady() {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow() {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh() {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom() {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage() {

	}
})